import {_decorator, Component, Node, screen, macro, view, director, game, profiler} from 'cc';

const {ccclass, property} = _decorator;
import 'minigame-api-typings';


@ccclass('FullScreenCtrl')
export class FullScreenCtrl extends Component {
    private screenWidth: number;
    private screenHeight: number;

    @property(Node)
    openAR: Node;

    @property(Node)
    btnEnterFullScreen: Node;

    @property(Node)
    btnExitFullScreen: Node;

    start() {
        game.frameRate = 59;

        const info = wx.getWindowInfo();
        this.screenWidth = info.screenWidth;
        this.screenHeight = info.screenHeight


    }

    test() {
    }


    onToggleStats() {
        if (profiler.isShowingStats()) {
            profiler.hideStats();
        } else {
            profiler.showStats();
        }
    }

    onEnterFullScreen() {
        view.setOrientation(macro.ORIENTATION_LANDSCAPE);
        screen.requestFullScreen();
    }

    onExitFullScreen() {
        screen.exitFullScreen();
    }

    update() {
        let isFullScreen = screen.fullScreen();
        this.btnEnterFullScreen.active = !isFullScreen;
        this.btnExitFullScreen.active = isFullScreen;
    }

    private createVKSessionInstance() {
        const isSupportV2 = wx.isVKSupport('v2');
        const vk = wx.createVKSession({
            track: {
                plane: {mode: isSupportV2 ? 3 : 1},
                marker: true,
                OSD: true
            },
            version: isSupportV2 ? 'v2' : 'v1',
            // gl, // WebGLRenderingContext
        });
        console.log('创建VKSession:', vk);
        return vk;
    }
}

